home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 015 / fflfnp.arc / FFLF50.ASM next >
Encoding:
Assembly Source File  |  1987-03-09  |  7.4 KB  |  138 lines

  1. ; FormFeed LineFeed    Version 5.0
  2. ; Memory-resident program to send form feed and line feed 
  3. ;    characters to printer
  4. ;        Alt-* [PrtSc] = form feed
  5. ;        Alt-/     = line feed
  6. ; Includes installation messages
  7. ; Checks printer status, beeps if printer not ready
  8.  
  9. ; Checks for prior installation by looking for four words of code.
  10. ; Uses interrupt 10h to generate beep.
  11.  
  12. ; Written in CHeap ASseMbler format by :
  13. ;       L. R. Holliday
  14. ;       218 Virginia
  15. ;       Ponca City, Oklahoma 74601
  16.  
  17. fflf          proc      far
  18.               jmps      set_up         ; Jump to initialize
  19. addr_bx       ds        2,0            ; Space to store KBINT offset
  20. addr_es       ds        2,0            ; Space to store KBINT segment
  21. flag          db        0fh
  22. new_kbint     sti                      ; Interrupts on
  23.               push      ax             ; Store registers
  24.               push      dx
  25.               mov       ah,02          ; Get shift state
  26.               int       16h            ;    through BIOS
  27.               test      al,08          ; Is Alt key pressed ?
  28.               jz        exit           ; If not, jump to exit
  29.               test      al,07          ; Is Ctrl or Shift key pressed ?
  30.               jnz       exit           ; If so, jump to exit
  31.               in        al,60h         ; Get key scan code
  32.               cmp       al,37h         ; Is it * [PrtSc] Key ?
  33.               jz        formfeed       ; If so, jump to Formfeed
  34.               cmp       al,35h         ; Is it / Key ?
  35.               jz        linefeed       ; If so, jump to Linefeed
  36.               jmps      exit           ; If none of above, jump to exit
  37. formfeed      mov       dx,0000        ; Select printer 1
  38.               mov       ah,02          ; check printer status
  39.               int       17h
  40.               cmp       ah,90h         ; is printer on-line ?
  41.               jnz       beep           ; if not, then beep
  42.               mov       ax,000Ch       ; Put Formfeed character in AL
  43.               int       17h            ; Send to printer
  44.               jmps      kb_reset       ; Jump to KeyBoard Reset
  45. linefeed      mov       dx,0000        ; Select printer 1
  46.               mov       ah,02          ; check printer status
  47.               int       17h
  48.               cmp       ah,90h         ; is printer on-line ?
  49.               jnz       beep           ; if not, then beep
  50.               mov       ax,000Ah       ; Put Linefeed character in AL
  51.               int       17h            ; Send to printer
  52.               jmps      kb_reset       ; Jump to KeyBoard Reset
  53. beep          mov       ah,0eh         ; Set for write to screen
  54.               mov       cx,0001        ; Number of characters to write
  55.               mov       al,07          ; Beep character
  56.               int       10h            ; Send to screen
  57. kb_reset      in        al,61h         ; These instructions reset the
  58.               mov       ah,al          ;     keyboard
  59.               or        al,80h         ;       ......
  60.               out       61h,al         ;       ......
  61.               mov       al,ah          ;       ......
  62.               out       61h,al         ;       ......
  63.               cli                      ; Turn interrupts off
  64.               mov       al,20h         ; Send End-of-Interrupt
  65.               out       20h,al         ;      signal
  66.               pop       dx             ; Restore registers
  67.               pop       ax
  68.               iret                     ; Return to interrupted program
  69. exit          pop       dx             ; Restore registers
  70.               pop       ax
  71.               seg       cs             ; cs:
  72.               jmpf      addr_bx        ; Return to old kbint
  73. set_up        mov       ah,30h         ; Check DOS Version
  74.               int       21h
  75.               cmp       al,2           ; Is it 2 or higher ?
  76.               jae       check          ; If so, check for prior installation
  77.               mov       dx,offset(err_msg2)
  78.               jmps      msg_exit       ; If not, issue error message
  79. check         mov       dx,offset(new_kbint)  ; Offset to begin search
  80.               mov       ax,cs          ; DS:SI points to destination
  81.               mov       es,ax          ; ES:DI points to source
  82. nextseg       dec       ax             ; Search previous segment
  83.               mov       ds,ax          ; Load new segment to search
  84.               mov       si,dx          ; Point to beginning of string
  85.               mov       di,dx          ; Point to beginning of string
  86.               mov       cx,0004h       ; Four words must match
  87.               cld                      ; Clear DF for autoincrement
  88.               repz                     ; Repeat until zero
  89.               cmpsw                    ; Compare words
  90.               jnz       notfound       ; If no match, keep trying
  91. ; If found, check to see if this is a local copy, rather than installed
  92.               cmpb      flag,0fh       ; Is this installed copy ?
  93.               jnz       installed      ; If installed, skip installation
  94. notfound      cmp       ax,0001h       ; Stop searching at low memory
  95.               jnz       nextseg        ; Keep trying if not
  96. install       seg       cs             ; cs:
  97.               movb      flag,00h       ; Set installation byte
  98.               mov       AX,3509h       ; Get BIOS KBINT address through
  99.               int       21h            ;     DOS GET_VECTOR service
  100.               seg       cs             ; cs:
  101.               mov       addr_bx,bx     ; Store offset and segment
  102.               seg       cs             ; cs:
  103.               mov       addr_es,es     ;      in spaces allocated
  104.               push      cs             ; Set DS to CS
  105.               pop       ds
  106.               mov       dx,offset(new_kbint)    ; Address of new kbint
  107.               mov       ax,2509h       ; Set vector to new kbint
  108.               int       21h            ;     through DOS SET_VECTOR service
  109.               mov       dx,offset(inst_msg)
  110.               mov       ah,9           ; Display installation message
  111.               int       21h
  112.               mov       dx,offset(set_up) ; Address of end of resident code
  113.               int       27h            ; Terminate, but stay resident
  114. installed     mov       dx,offset(err_msg1)
  115. msg_exit      mov       ah,9           ; Display error message
  116.               push      cs
  117.               pop       ds             ; Restore DS
  118.               int       21h
  119.               int       20h            ; Terminate
  120. end           endp
  121.  
  122. inst_msg      db  13,10,'    FORMFEED - LINEFEED    Version  5.0',13,10
  123.               db  13,10,'    by L. R. Holliday',13,10
  124.               db  13,10,'    Printer FormFeed and LineFeed Program',13,10
  125.               db  13,10,'    Memory-Resident Portion Installed',13,10
  126.               db  13,10,'Press  Alt-*   to Send FormFeed to Printer',13,10
  127.               db  13,10,'Press  Alt-/   to Send LineFeed to Printer',13,10,36
  128.  
  129. err_msg1      db  13,10,'    FORMFEED - LINEFEED    Version  5.0',13,10
  130.               db  13,10,'    by L. R. Holliday',13,10
  131.               db  13,10,'    Printer FormFeed and LineFeed Program',13,10
  132.               db  07,13,10,'    --- Already Installed ---',13,10,36
  133.  
  134. err_msg2      db  13,10,'    FORMFEED - LINEFEED    Version  5.0',13,10
  135.               db  13,10,'    by L. R. Holliday',13,10
  136.               db  13,10,'    Printer FormFeed and LineFeed Program',13,10
  137.               db  07,13,10,'    --- Wrong Dos Version ---',13,10,36
  138.